﻿using System;
using System.Threading;

namespace SingletonPattern
{
    class Program
    {
        static NestedSingleton singleton = null;

        static void Main(string[] args)
        {
            var thread1 = new Thread(new ThreadStart(GetInstance));
            var thread2 = new Thread(new ThreadStart(GetInstance));
            thread1.Start();
            thread2.Start();
            Thread.Sleep(1000);
            var thread3 = new Thread(new ThreadStart(GetInstance));
            thread3.Start();

            Console.ReadKey();
        }

        static void GetInstance()
        {
            singleton = NestedSingleton.Instance;
            Console.WriteLine("singleton->hashCode is {0}", singleton.GetHashCode());
        }
    }
}